#!/bin/sh

# Use fixed commit auther and committer
GIT_AUTHOR_EMAIL=author@example.com
GIT_AUTHOR_NAME='A U Thor'
GIT_COMMITTER_EMAIL=committer@example.com
GIT_COMMITTER_NAME='C O Mitter'
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME

test_tick () {
	if test -z "${test_tick+set}"
	then
		test_tick=1112911993
	else
		test_tick=$(($test_tick + 60))
	fi
	GIT_COMMITTER_DATE="$test_tick -0700"
	GIT_AUTHOR_DATE="$test_tick -0700"
	export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
}


generate_commits() {
	from=0
	to=
	case $# in
	1)
		to=$1
		;;
	2)
		from=$1
		to=$2
		;;
	*)
		echo >&2 "Usage: generate_commits <num> [<num>]"
		return 1
		;;
	esac

	for i in $(seq $from $to)
	do
		file="file$i"
		touch "$file"
		# echo "content of file $i" >"$file"
		git add "$file"
		test_tick && git commit -m "$file"
	done
}
